package com.sltx.service.impl;

import com.sltx.util.BigDataUtils;
import com.sltx.util.Conversion;
import com.sltx.util.PageData;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.CrossOrigin;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;

@Service("QjcxService")
@CrossOrigin
public class QjcxServiceImpl implements Serializable {


    private static final long serialVersionUID = -7803837915760279469L;


    /**
     * 登记信息
     */
    public List<Map<String, Object>> getRegisterInfo(PageData pd) {
        List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();

        JSONObject jo = Conversion.getServiceData("getRegisterInfo", pd);
        List<Map<String, Object>> list = jo.getJSONArray("RESULTDATA");
        //Map<String,Object> pageInfo = (Map<String, Object>) jo.get("PAGEINFO");

        for (Map<String, Object> map : list) {
            if (map.get("WEBSITE") != null && !map.get("WEBSITE").toString().equals("")) {
                if (!map.get("WEBSITE").toString().contains("http")) {
                    map.put("WEBSITE", "http://" + map.get("WEBSITE"));
                }
            }
            result.add(map);
        }
        return result;
    }

    /**
     * 所在写字楼
     */
    public Map<String, Object> getEntOfficeBuildingInfo(PageData pd) {

        Map<String, Object> result = new HashMap<String, Object>();


        JSONObject jo = Conversion.getServiceData("entOfficeBuildingInfo", pd);
        List<Map<String, Object>> list = jo.getJSONArray("RESULTDATA");
        Map<String, Object> pageInfo = (Map<String, Object>) jo.get("PAGEINFO");

        result.put("entOfficeBuildingInfo", list);
        result.put("pageInfo", pageInfo);


        return result;
    }

    /**
     * 企业标签
     */
    public Map<String, Object> getEntLable(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "50");
        }

        JSONObject jsonObj = Conversion.getServiceData("getEntLable", pd);
        result.put("getEntLable", jsonObj.getJSONArray("RESULTDATA"));
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 股东出资信息
     */
    public Map<String, Object> getShareHolderInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }

        JSONObject jsonObj = Conversion.getServiceData("getShareHolderInfo", pd);
        List<Map<String, Object>> list = jsonObj.getJSONArray("RESULTDATA");
        for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < list.size() - i - 1; j++) {

                Map<String, Object> tmp1 = list.get(j);
                Map<String, Object> tmp2 = list.get(j + 1);
                double d1 = 0;
                double d2 = 0;
                if (tmp1.get("SUBCONAM") != null && !tmp1.get("SUBCONAM").equals("")) {
                    d1 = Double.parseDouble(tmp1.get("SUBCONAM").toString());
                }
                if (tmp2.get("SUBCONAM") != null && !tmp2.get("SUBCONAM").equals("")) {
                    d2 = Double.parseDouble(tmp2.get("SUBCONAM").toString());
                }
                if (d1 < d2) {
                    Map<String, Object> temp = tmp1;
                    list.remove(j);
                    list.add(j, tmp2);
                    list.remove(j + 1);
                    list.add(j + 1, temp);
                }
            }
        }
        List<Map<String, Object>> resultMap = new ArrayList<Map<String, Object>>();
        DecimalFormat df = new DecimalFormat("0.00");
        for (int i = 0; i < list.size(); i++) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("INV", list.get(i).get("INV"));
            map.put("INVTYPE", list.get(i).get("INVTYPE"));
            map.put("SUBCONAM", list.get(i).get("SUBCONAM"));
            map.put("CONCUR", list.get(i).get("CONCUR"));
            map.put("CONRATIO", df.format(Double.parseDouble(list.get(i).get("CONRATIO").toString()) * 100) + "%");
            resultMap.add(map);
        }
        result.put("getShareHolderInfo", resultMap);
        result.put("pageInfo", jsonObj.get("PAGEINFO"));
        return result;
    }

    /**
     * 主要管理人员
     */
    public Map<String, Object> getMainManagerInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }

        JSONObject jsonObj = Conversion.getServiceData("getMainManagerInfo", pd);
        List<Map<String, Object>> list = jsonObj.getJSONArray("RESULTDATA");
        Map<String, Object> map = new HashMap<String, Object>();
        Map<String, Object> resultMap = new HashMap<String, Object>();
        List<Map<String, Object>> custodian1 = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> custodian2 = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> custodian3 = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> custodian4 = new ArrayList<Map<String, Object>>();
        for (int i = 0; i < list.size(); i++) {
            map = list.get(i);
            if (map.get("POSITION").toString().contains("监事")) {
                custodian2.add(map);
            } else if (map.get("POSITION").toString().contains("董事")) {
                custodian1.add(map);
            } else if (map.get("POSITION").toString().contains("经理")) {
                custodian3.add(map);
            } else {
                custodian4.add(map);
            }
        }
        resultMap.put("custodian2", custodian2);
        resultMap.put("custodian1", custodian1);
        resultMap.put("custodian3", custodian3);
        resultMap.put("custodian4", custodian4);
        result.put("getMainManagerInfo", resultMap);
        result.put("pageInfo", jsonObj.get("PAGEINFO"));
        return result;
    }

    /**
     * 变更信息
     */
    public Map<String, Object> getRegisterChangeInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }

        JSONObject jsonObj = Conversion.getServiceData("getRegisterChangeInfo", pd);
        result.put("getRegisterChangeInfo", jsonObj.getJSONArray("RESULTDATA"));
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 股权出质
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEquityPledgedInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getEquityPledgedInfo", pd);

        result.put("getEquityPledgedInfo", jsonObj.getJSONArray("RESULTDATA"));//股权出质
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 动产抵押
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getChattelMortgageInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getChattelMortgageInfo", pd);

        result.put("getChattelMortgageInfo", jsonObj.getJSONArray("RESULTDATA"));//动产抵押
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 企业对外投资
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getInvestmentAbroadInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getInvestmentAbroadInfo", pd);

        result.put("getInvestmentAbroadInfo", jsonObj.getJSONArray("RESULTDATA"));
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 分支机构
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getBranchInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getBranchInfo", pd);

        result.put("getBranchInfo", jsonObj.getJSONArray("RESULTDATA"));//分支机构
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 法人代表对外投资
     *
     * @param pd
     * @return
     */
    public Map<String, Object> lawPersonInvestmentInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("lawPersonInvestmentInfo", pd);

        result.put("lawPersonInvestmentInfo", jsonObj.getJSONArray("RESULTDATA"));//法人代表对外投资
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 法人代表其他公司任职
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getLawPersontoOtherInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getLawPersontoOtherInfo", pd);

        result.put("getLawPersontoOtherInfo", jsonObj.getJSONArray("RESULTDATA"));//法人代表其他公司任职
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 主要管理人员对外投资
     *
     * @param pd
     * @return
     */
    public Map<String, Object> mainPersonInvestmentInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("mainPersonInvestmentInfo", pd);

        result.put("mainPersonInvestmentInfo", jsonObj.getJSONArray("RESULTDATA"));//主要管理人员对外投资
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 主要管理人员其他公司任职
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getManagertoOtherInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getManagertoOtherInfo", pd);

        result.put("getManagertoOtherInfo", jsonObj.getJSONArray("RESULTDATA"));//主要管理人员其他公司任职
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 企业年报基本信息
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntAnnReportInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        JSONObject jsonObj = Conversion.getServiceData("getEntAnnReportInfo", pd);

        result.put("getEntAnnReportInfo", jsonObj.getJSONArray("RESULTDATA"));//企业年报基本信息

        return result;
    }

    /**
     * 企业年报网站网店信息
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntAnnReportWebSiteInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        JSONObject jsonObj = Conversion.getServiceData("getEntAnnReportWebSiteInfo", pd);

        result.put("getEntAnnReportWebSiteInfo", jsonObj.getJSONArray("RESULTDATA"));//企业年报网站网店信息

        return result;
    }

    /**
     * 企业年报股东及出资信息
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntAnnReportInvInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        JSONObject jsonObj = Conversion.getServiceData("getEntAnnReportInvInfo", pd);

        result.put("getEntAnnReportInvInfo", jsonObj.getJSONArray("RESULTDATA"));//企业年报股东及出资信息

        return result;
    }

    /**
     * 企业年报对外投资信息
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntAnnReportToInvInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        JSONObject jsonObj = Conversion.getServiceData("getEntAnnReportToInvInfo", pd);

        result.put("getEntAnnReportToInvInfo", jsonObj.getJSONArray("RESULTDATA"));//企业年报对外投资信息

        return result;
    }

    /**
     * 企业年报资产状况信息
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntAnnReportAssetsInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        JSONObject jsonObj = Conversion.getServiceData("getEntAnnReportAssetsInfo", pd);
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        list = jsonObj.getJSONArray("RESULTDATA");

        result.put("getEntAnnReportAssetsInfo", list);//企业年报资产状况信息

        return result;
    }

    /**
     * 企业年报对外担保信息
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntAnnReportForGuaranteeInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        JSONObject jsonObj = Conversion.getServiceData("getEntAnnReportForGuaranteeInfo", pd);

        result.put("getEntAnnReportForGuaranteeInfo", jsonObj.getJSONArray("RESULTDATA"));//企业年报对外担保信息

        return result;
    }

    /**
     * 企业年报股权变更信息
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntAnnReportStockChanageInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        JSONObject jsonObj = Conversion.getServiceData("getEntAnnReportStockChanageInfo", pd);

        result.put("getEntAnnReportStockChanageInfo", jsonObj.getJSONArray("RESULTDATA"));//企业年报股权变更信息

        return result;
    }

    /**
     * 企业年报社保信息
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntAnnReportSocialSecurityInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        JSONObject jsonObj = Conversion.getServiceData("getEntAnnReportSocialSecurityInfo", pd);

        result.put("getEntAnnReportSocialSecurityInfo", jsonObj.getJSONArray("RESULTDATA"));//企业年报社保信息

        return result;
    }

    /**
     * 招投标
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getBiddingInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getBiddingInfo", pd);

        result.put("getBiddingInfo", jsonObj.getJSONArray("RESULTDATA"));//招投标
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 企业资质
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getQualifyCertifyInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getQualifyCertifyInfo", pd);

        result.put("getQualifyCertifyInfo", jsonObj.getJSONArray("RESULTDATA"));//企业资质
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 企业荣誉
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntHonorInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getEntHonorInfo", pd);

        result.put("getEntHonorInfo", jsonObj.getJSONArray("RESULTDATA"));//企业荣誉
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 企业专利列表
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getPatentInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getPatentInfo", pd);

        result.put("getPatentInfo", jsonObj.getJSONArray("RESULTDATA"));
        result.put("pageInfo", jsonObj.get("PAGEINFO"));
        return result;
    }

    /**
     * 企业商标列表
     */
    public Map<String, Object> getTrademarkInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }

        JSONObject jsonObj = Conversion.getServiceData("getTrademarkInfo", pd);
        List<Map<String, Object>> RESULTDATA = jsonObj.getJSONArray("RESULTDATA");
        List<Map<String, Object>> getTrademarkInfo = new ArrayList<Map<String, Object>>();
        for (int i = 0; i < RESULTDATA.size(); i++) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("MARKNAME", RESULTDATA.get(i).get("MARKNAME"));
            map.put("APPDATE", RESULTDATA.get(i).get("APPDATE"));
            map.put("MARKCODE_KEY", RESULTDATA.get(i).get("MARKCODE_KEY"));
            map.put("UNIONTYPE", RESULTDATA.get(i).get("UNIONTYPE"));
            map.put("UNIONTYPENAME", RESULTDATA.get(i).get("UNIONTYPENAME"));
            map.put("ISINVALID", RESULTDATA.get(i).get("ISINVALID"));
            map.put("ROWKEY", RESULTDATA.get(i).get("ROWKEY"));
            getTrademarkInfo.add(map);
        }
        result.put("getTrademarkInfo", getTrademarkInfo);
        result.put("pageInfo", jsonObj.get("PAGEINFO"));//页面信息

        return result;
    }


    /**
     * 企业作品著作权信息
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getWorksCopyrightInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getWorksCopyrightInfo", pd);

        result.put("getWorksCopyrightInfo", jsonObj.getJSONArray("RESULTDATA"));
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 企业软件著作权信息
     */
    public Map<String, Object> getSoftwareCopyrightInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getSoftwareCopyrightInfo", pd);

        result.put("getSoftwareCopyrightInfo", jsonObj.getJSONArray("RESULTDATA"));
        result.put("pageInfo", jsonObj.get("PAGEINFO"));//页面信息

        return result;
    }

    /**
     * 法院执行人
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getBePerformedInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getBePerformedInfo", pd);

        result.put("getBePerformedInfo", jsonObj.getJSONArray("RESULTDATA"));//法院执行人
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 裁判文书
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getExecuteJudgmentInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getExecuteJudgmentInfo", pd);

        result.put("getExecuteJudgmentInfo", jsonObj.getJSONArray("RESULTDATA"));//裁判文书
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 终本案件
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getFinalCaseInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getFinalCaseInfo", pd);

        result.put("getFinalCaseInfo", jsonObj.getJSONArray("RESULTDATA"));//终本案件
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 高管失信
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntManagerLostInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getEntManagerLostInfo", pd);

        result.put("getEntManagerLostInfo", jsonObj.getJSONArray("RESULTDATA"));//高管失信

        return result;
    }

    /**
     * 失信人
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getLostCreditInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getLostCreditInfo", pd);

        result.put("getLostCreditInfo", jsonObj.getJSONArray("RESULTDATA"));//失信人
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 发展历程
     */
    public Map<String, Object> getEntChronicleInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "1000");
        }

        JSONObject jsonObj = Conversion.getServiceData("getEntChronicleInfo", pd);
        List<Map<String, Object>> list = jsonObj.getJSONArray("RESULTDATA");
        List<Map<String, Object>> chronicle = new ArrayList<Map<String, Object>>();
        TreeSet<String> set = new TreeSet<String>();
        for (int i = 0; i < list.size(); i++) {
            String year = list.get(i).get("MONTH").toString();
            if (year != null && !year.equals("")) {
                String yearKey = year.substring(0, 4);
                set.add(yearKey);
            }
        }
        List<String> years = new ArrayList<String>(set);
        Collections.sort(years, Collections.reverseOrder());

        for (String year : years) {

            Map<String, Object> temp = new HashMap<String, Object>();
            List<Map<String, Object>> array = new ArrayList<Map<String, Object>>();
            for (int i = 0; i < list.size(); i++) {
                if (year.equals(list.get(i).get("MONTH").toString().substring(0, 4))) {
                    array.add(list.get(i));
                }
            }
            temp.put(year, array);
            chronicle.add(temp);
        }

        Map<String, LinkedHashMap<String, Object>> infoByYearGroupCount = BigDataUtils.getInfoByYearGroupCount(list);
        LinkedHashMap<String, Object> infoByGroupCount = BigDataUtils.getInfoByGroupCount(list);
        result.put("yearCountMap", infoByYearGroupCount);
        result.put("totalGroupCount", infoByGroupCount);
        result.put("chronicle", chronicle);
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 行政许可
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getAdministrativeLicensingInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getAdministrativeLicensingInfo", pd);

        result.put("getAdministrativeLicensingInfo", jsonObj.getJSONArray("RESULTDATA"));
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 行政处罚
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getAdministrativePenaltyInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getAdministrativePenaltyInfo", pd);

        result.put("getAdministrativePenaltyInfo", jsonObj.getJSONArray("RESULTDATA"));//失信人
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 红名单
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getTrustworthyInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getTrustworthyInfo", pd);

        result.put("getTrustworthyInfo", jsonObj.getJSONArray("RESULTDATA"));//失信人


        return result;
    }

    /**
     * 黑名单
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getLostTrustInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getLostTrustInfo", pd);

        result.put("getLostTrustInfo", jsonObj.getJSONArray("RESULTDATA"));//失信人

        return result;
    }

    /**
     * 企业项目
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getEntProgramInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getEntProgramInfo", pd);

        result.put("getEntProgramInfo", jsonObj.getJSONArray("RESULTDATA"));
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }

    /**
     * 新闻舆情
     */
    public List<Map<String, Object>> getRiskStormEventInfo(PageData pd) {
        if (pd.get("entities") != null && !pd.get("entities").equals("")) {
            pd.put("entities", Conversion.codeConversion(pd.get("entities").toString()));
        }
        if (pd.get("category") != null && !pd.get("category").equals("")) {
            pd.put("category", Conversion.codeConversion(pd.get("category").toString()));
        }
        if (pd.get("alias") != null && !pd.get("alias").equals("")) {
            pd.put("alias", Conversion.codeConversion(pd.get("alias").toString()));
        }
        if (pd.get("startTime") == null || "".equals(pd.get("startTime"))) {
            pd.put("startTime", "1980-01-01");
        }
        if (pd.get("endTime") == null || "".equals(pd.get("endTime"))) {
            pd.put("endTime", new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        }
        List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();

        JSONObject jo = Conversion.getServiceData("getRiskStormEventInfo", pd);

        List<Map<String, Object>> list = jo.getJSONArray("RESULTDATA");

        Map<String, Object> resultMap = new HashMap<String, Object>();
        Map<String, Object> map1 = new HashMap<String, Object>();
        Map<String, Object> map2 = new HashMap<String, Object>();
        Map<String, Object> map3 = new HashMap<String, Object>();
        List<Object> list1 = new ArrayList<Object>();
        List<Map<String, Object>> list2 = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> list3 = new ArrayList<Map<String, Object>>();
        for (Map<String, Object> resultArr : list) {
            map1 = (Map<String, Object>) resultArr.get("EVENT");
            map2 = (Map<String, Object>) resultArr.get("ENTITY");
            map3 = (Map<String, Object>) resultArr.get("ALIAS");
            list1 = (List<Object>) map1.get("HITS");
            list2.add(map2);
            list3.add(map3);
        }
        resultMap.put("getNewsContent", list1);
        resultMap.put("getRelated", list2);
        resultMap.put("getKerword", list3.get(0).get("KEYWORDS"));
        result.add(resultMap);
        return result;
    }

    /**
     * 网络招聘
     *
     * @param pd
     * @return
     */
    public Map<String, Object> getRecruitmentInfo(PageData pd) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (pd.getString("pageNo") == null) {
            pd.put("pageNo", "1");
        }
        if (pd.getString("pageSize") == null) {
            pd.put("pageSize", "5");
        }
        JSONObject jsonObj = Conversion.getServiceData("getRecruitmentInfo", pd);

        result.put("getRecruitmentInfo", jsonObj.getJSONArray("RESULTDATA"));
        result.put("pageInfo", jsonObj.get("PAGEINFO"));

        return result;
    }
}
